package com.zhixing.web.service.exception.handler;

import com.zhixing.web.api.dataobject.untils.ResultVoUtil;
import com.zhixing.web.api.dataobject.vo.ResultVO;
import com.zhixing.web.service.exception.GlobalException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author dzh
 * @version 1.0.0.05020
 * <p>project: d-blog</p>
 * <p>created time: 2022/05/05 15:32</p>
 * <p>describe: 全局异常</p>
 * <p>remarks: </p>
 **/
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandle {

    /**
     * <p>描述：全局异常捕获</p>
     *
     * @author dzh
     * @param globalexception 全局异常捕获
     * @return ResultVO
     * <p>时间：2022/05/05 21:43</p>
     **/
    @ExceptionHandler(value = GlobalException.class)
    @ResponseBody
    public ResultVO globalExceptionHandle(GlobalException globalexception) {

        return ResultVoUtil.error(globalexception.getCode(), globalexception.getMessage());
    }
}
